class RoomTypeMain extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            tyep: 0
        };
    }

    tabOnChange(index) {
        this.setState({
            tyep: index
        });
    }

    createRoomType() {
        this.refs.roomType.createRoomType();
    }

    createRoomTypeGroup() {
        this.refs.roomTypeGroup.createRoomTypeGroup();
    }

    render() {

        return (
            <Frame header="户型管理" headerBtns={
                this.state.tyep === 0 ?
                    <HeaderBtn onClick={() => this.createRoomType()}><i className="fa fa-plus"/>&nbsp;创建户型</HeaderBtn>
                    :
                    <HeaderBtn onClick={() => this.createRoomTypeGroup()}><i className="fa fa-plus"/>&nbsp;
                        创建户型组</HeaderBtn>
            }
            >
                <Tab titles={['户型列表', '户型组列表']} ids={['0', '1']} type="brief"
                     onChange={(index) => this.tabOnChange(index)} ref="tab">
                    <TabItem show="true">
                        <RoomType ref="roomType"/>
                    </TabItem>
                    <TabItem>
                        <RoomTypeGroup ref="roomTypeGroup"/>
                    </TabItem>
                </Tab>
            </Frame>
        )
    }
}

ReactDOM.render(<RoomTypeMain/>, document.getElementById('root'));